<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>注册</title>
</head>
<body>
	${msg!}
	<br />

	<input type="text" name="email" /> <button class="sendMsg" clickable="1">发送短信验证码</button>
	<br />

	<button class="register" type="button">注册</button>

	<script src="${ctxPath}/assets/js/jquery.min.js"></script>
	<script type="text/javascript">
		$(function(){
			$(".register").click(function(){
				//获取email的值
				var email = $("input[name='email']").val();
				$.ajax({
					url:'${ctxPath}/register'
					,type:'POST'
					,data:{"email":email}
					,success:function(data){
						alert(data);
					}					
				})
			})	
			
			// http://www.jb51.net/article/35535.htm
			$(".sendMsg").click(function(){
				var clickable = $(this).attr("clickable");
				console.log("clickable:"+clickable);
				if(clickable=="0"){	
					alert("不能点了");			
					return;
				}
				//启动倒计时
				msgTimeOut();
				
				//设置不能点击了
				$(this).attr("clickable","0");
				
			})		
		})
		var msgTime = 10;
		function msgTimeOut(){
			if(msgTime ==0){
				console.log("执行中");
				$(".sendMsg").attr("clickable","1");
				$(".sendMsg").html("发送短信验证码");
				msgTime = 10;
				return;
			}
			msgTime--;
			$(".sendMsg").html(msgTime);
			setTimeout("msgTimeOut()",1000);
		}
	</script>
</body>
</html>